# -*- coding: utf-8 -*-

#配置文件读取模块
#读取config.in文件
class ConfigReader():
    
    config_map = {}
    
    def __init__(self):
        try:
            fp = open(r'./config.in', 'r')
            
            while True:
                line = fp.readline()
                if not line:
                    break
                
                config_list = line.split('=')
                self.config_map[config_list[0]] = config_list[1]
            
            
        except IOError:
            print 'Open <config.in> failed'
            
            if not fp:
                fp.close()
                
            return None
        
        except:
            print 'Unkown exception'
            
            if not fp:
                fp.close()
            
            return None
        
        if not fp:
            fp.close()
            
        return
    
    def getConfigItem(self, name):
        if not name:
            print 'Invaild param: name'
            
            return 
        
        return self.config_map[name]
    
    def __del__(self):
        pass